package com.pet.server.utils;

public class ResultUtil<T> {
  private int code;
  private String msg;
  private T data;

  /**
   * 成功调用构造器
   *
   * @param data 要返回的数据
   */
  public ResultUtil(T data) {
    this.code = 0;
    this.msg = "success";
    this.data = data;
  }

  /**
   * 失败调用构造器
   *
   * @param msg 错误信息
   */
  public ResultUtil(String msg) {
    this.code = 0;
    this.msg = msg;
  }

  public int getCode() {
    return code;
  }

  public String getMsg() {
    return msg;
  }

  public T getData() {
    return data;
  }

  @Override
  public String toString() {
    return "ResultUtil{" + "code=" + code + ", msg='" + msg + '\'' + ", data=" + data + '}';
  }
}
